'use strict'
//1.
var arr = [1, 2, 3, 4];
var item = 3;
var bool = arr.indexOf(item);
if (bool > 0) {
    console.log(item);
} else {
    console.log(-1);
}

//2.
var arr2 = [1, 2, 3, 4];

var sum = 0;
for (var i = 0; i <= arr2.length - 1; i++) {
    sum += arr2[i];
}
console.log(sum);


//3.
var arr3 = [1, 2, 3, 4, 2];
for (var i = 0; i <= arr3.length - 1; i++) {
    if (arr3[i] != 2) {
        var a = [];
        a.push = arr3[i];
        console.log(a);
    }

}


//4.
var arr4 = [1, 2, 2, 3, 4, 2, 2];
for (var i = 0; i <= arr4.length - 1; i++) {
    if (arr4[i] === 2) {
        arr4.splice(arr4[i], 1);
    }
}
console.log(arr4);


//5.
var arr5 = [1, 2, 3, 4];
var b = [];
b.push = arr5.push(10);

//6.
var arr6 = [1, 2, 3, 4];
var c = [];
c.push = arr6.pop();

//7.
var arr7 = [1, 2, 3, 4];
var d = [];
d.push = arr7.unshift(10);

//8.
var arr8 = [1, 2, 3, 4];
var e = [];
e.push = arr8.shift();

//9.
var arr9 = [1, 2, 3, 4];
var list = ['a', 'b', 'c', 1];
var f = [];
f.push = arr9.concat(list);

//10.
var arr10 = [1, 2, 3, 4];
var g = [];
g.push = arr10.splice(2, 0, 'z');

//11.
var arr11 = [1, 2, 4, 4, 3, 4, 3];
for (var i = 0; i <= arr11.length - 1; i++) {
    if (arr11[i] === 4) {
        var h = 1 + h;
        console.log(h);
    }
}


//12.
var arr12 = [1, 2, 4, 4, 3, 3, 1, 5, 3];
for (var i = 0; i <= arr12.length - 1; i++) {
    var index = arr12.indexOf(arr12[i]);
    if (index > 0) {
        arr12.reverse();
        var index2 = arr12.indexOf(arr12[i]);
        if (index != index2) {
            var j = [];
            j.push = arr12[i];
            arr12.reverse();
            console.log(j);
        }
    }
}


//13.
var arr13 = [1, 2, 3, 4];
for (var i = 0; i <= arr12.length - 1; i++) {
    var k = [];
    k.push = arr13[i] * arr13[i];
    console.log(k);
}


//14.
var str = 'abcdefabc';
for (var i = 0; i <= str.length - 1; i++) {
    for (var p = 0; p <= str.length - 1 && p > i; p++) {
        if (str[i] === str[p]) {
            var l = [];
            l.push = str.indexOf(str[i]);
            l.push = str.indexOf(str[p]);
            console.log(l);
        }
    }
}